<?php
/**
 * Created by PhpStorm.
 * User: xi
 * Date: 2020-05-02
 * Time: 16:54
 */

namespace app\api\service;


use app\admin\model\Roomclean;
use app\admin\model\Shop;
use app\admin\model\Shoporder;
use app\admin\model\Shoporderprofit;
use app\admin\model\Shoproom;
use app\admin\model\Shoproombook;
use app\admin\model\Shopstaff;
use app\admin\model\Userorderprofit;
use app\admin\model\Usertuan;
use app\admin\model\Userwithdraw;
use fast\Http;

class OrderService
{

    public function sync($id)
    {
        $shopOrderModel = new Shoporder();
        $order = $shopOrderModel->where('id',$id)->find();
        if(!$order){
            $this->error("订单不存在");
        }
        $roomModel = new Shoproom();
        $room = $roomModel->where('id',$order['room_id'])->find();
        if($room['mai_id'] != -1){

            $shopModel = new Shop();
            $shop = $shopModel->where('id',$room['shop_id'])->find();
            $orderBookModel = new Shoproombook();
            $book = $orderBookModel->where('order_id',$order['id'])->find();

            $userModel = new \app\admin\model\User();
            $user = $userModel->where('id',$book['user_id'])->find();

            $cleanRoomModel = new Roomclean();
            $clean = $cleanRoomModel->where('order_id',$order['id'])->find();

            $ret = array();
            $ret['shop_id'] =$shop['mai_id'];
            $ret['room_id'] = $room['mai_id'];
            $ret['mobile'] = $user['mobile'];
            $ret['order'] = $order;
            $ret['book'] = $book;
            $ret['clean'] = $clean;

            $url = "https://app.quexiaqp.com/api/app/sync/order";

            Http::post($url, $ret);

        }

    }



}